package com.cupk.mapper;

import com.cupk.pojo.Topic;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TopicMapper {
    @Select("select * from topic where stage_id = #{stageId}")
    List<Topic> getTopicByStageId(Integer stageId);

    @Select("select max(question_id) from topic where stage_id = #{stageId}")
    Integer findMaxQuestion(Integer stageId);

    @Insert("insert into topic(stage_id,question_id,question_text,question_choice,question_type)" + " values (#{stageId},#{questionId},#{questionText},#{questionChoice},#{questionType})")
    void addTopic(Topic topic);

    @Select("select * from topic where id = #{topicId}")
    Topic getTopicById(Integer topicId);

    @Update("update topic set question_text = #{questionText}, question_choice = #{questionChoice}, question_type = #{questionType} where id = #{id}")
    void updateTopic(Topic topic);

    @Delete("delete from topic where id = #{topicId}")
    void deleteTopic(Integer topicId);

    List<String> getTopicQuestion(Integer stageId);
}
